/*
 * ServerAdminApplication.java
 *
 * Created on December 5, 2007, 11:59 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.atomojo.app.admin;

import java.util.Map;
import org.atomojo.app.StorageFactory;
import org.atomojo.app.WebComponent;
import org.atomojo.app.db.DBInfo;
import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.routing.Router;
import org.restlet.routing.Template;

/**
 *
 * @author alex
 */
public class ServerAdminApplication extends Application
{
   
   /** Creates a new instance of ServerAdminApplication */
   public ServerAdminApplication(Context context,Map<String,DBInfo> dbList,Map<String,DBInfo> autodbList,StorageFactory storageFactory)
   {
      super(context);
      getContext().getAttributes().put(WebComponent.ATOMOJO_TMP_DIR,context.getAttributes().get(WebComponent.ATOMOJO_TMP_DIR));
      getContext().getAttributes().put(DatabaseListResource.DB_LIST,dbList);
      getContext().getAttributes().put(DatabaseListResource.AUTO_DB_LIST,autodbList);
      getContext().getAttributes().put(DatabaseListResource.STORAGE_FACTORY,storageFactory);
      getTunnelService().setEnabled(false);
   }
   
   @Override
   public Restlet createRoot() {   
      Router router = new Router(getContext());
      router.attach("/database/",DatabaseListResource.class);
      router.attach("/database/backup",AllDatabaseBackupResource.class);
      router.attach("/database/restore",AllDatabaseRestoreResource.class);
      return router;
   }
}
